<!DOCTYPE html>
<html>

	<head>
		<meta charset="utf-8">
		<meta http-equiv="X-UA-Compatible" content="IE=edge">
		<title>登录</title>
		<!-- Tell the browser to be responsive to screen width -->
		<meta content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no" name="viewport">
		<!-- Bootstrap 3.3.7 -->
		<link rel="stylesheet" href="static/plugins/bower_components/bootstrap/dist/css/bootstrap.min.css">
		<!-- Font Awesome -->
		<link rel="stylesheet" href="static/plugins/bower_components/font-awesome/css/font-awesome.min.css">
		<!-- Ionicons -->
		<link rel="stylesheet" href="static/plugins/bower_components/Ionicons/css/ionicons.min.css">
		<!-- Theme style -->
		<link rel="stylesheet" href="static/dist/css/AdminLTE.min.css">
		<!-- iCheck -->
		<link rel="stylesheet" href="static/plugins/iCheck/square/blue.css">

		<!-- HTML5 Shim and Respond.js IE8 support of HTML5 elements and media queries -->
		<!-- WARNING: Respond.js doesn't work if you view the page via file:// -->
		<!--[if lt IE 9]>
  <script src="https://oss.maxcdn.com/html5shiv/3.7.3/html5shiv.min.js"></script>
  <script src="https://oss.maxcdn.com/respond/1.4.2/respond.min.js"></script>
  <![endif]-->

		<!-- Google Font -->
		<link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Source+Sans+Pro:300,400,600,700,300italic,400italic,600italic">
		<link rel="stylesheet" href="static/plugins/bootstrap-validator/dist/css/bootstrapValidator.min.css" />
		<style type="text/css">
			.alert-danger{
				display: none;
			}
		</style>

	</head>

	<body class="hold-transition login-page">
		
		<div class="alert alert-danger" role="alert">
		  <a href="#" class="alert-link">用户名或者密码不正确</a>
		</div>
		
		
		<div class="login-box">
			<div class="login-logo">
				<a href="static/index2.html"><b>用户管理</b>系统</a>
			</div>
			<!-- /.login-logo -->
			<div class="login-box-body">
				<p class="login-box-msg">登录</p>

				<form action="" method="post" id="defaultForm">
					<div class="form-group has-feedback">
						<input type="text" class="form-control show_name" placeholder="请输入用户名" name="username">
						<!--<span class="glyphicon glyphicon-user  form-control-feedback"></span>-->
					</div>
					
					<div class="form-group has-feedback">
						<input type="password" class="form-control show_pas" placeholder="请输入密码" name="password">
						<!--<span class="glyphicon glyphicon-lock form-control-feedback"></span>-->
					</div>
					<div class="row">
						<div class="col-xs-8">
							<div class="checkbox icheck">
								<label>
					              <input type="checkbox"> 记住密码
					            </label>
							</div>
						</div>
						<!-- /.col -->
						<div class="col-xs-4">
							<button type="submit" class="btn btn-primary btn-block btn-flat ">登录</button>
						</div>
						<!-- /.col -->
					</div>
				</form>

				<div class="social-auth-links text-center">
					<p>- OR -</p>
					<a href="#" class="btn btn-block btn-social btn-facebook btn-flat"><i class="fa fa-facebook"></i> Sign in using Facebook
					</a>
					<a href="#" class="btn btn-block btn-social btn-google btn-flat"><i class="fa fa-google-plus"></i> Sign in using Google+
					</a>
				</div>
				<!-- /.social-auth-links -->

				
			</div>
			<!-- /.login-box-body -->
		</div>
		<!-- /.login-box -->






		<!-- jQuery 3 -->
		<script src="static/plugins/bower_components/jquery/dist/jquery.min.js"></script>
		<!-- Bootstrap 3.3.7 -->
		<script src="static/plugins/bower_components/bootstrap/dist/js/bootstrap.min.js"></script>
		<!-- iCheck -->
		<script src="static/plugins/iCheck/icheck.min.js"></script>
		
		<script type="text/javascript" src="static/plugins/bootstrap-validator/dist/js/bootstrapValidator.min.js" ></script>
		<script type="text/javascript" src="static/plugins/bootstrap-validator/dist/js/language/zh_CN.js" ></script>

		<script src="/static/js/menu.js"></script>
		<script>
			$(function() {
				
//				location.href = "/login";
				$('input').iCheck({
					checkboxClass: 'icheckbox_square-blue',
					radioClass: 'iradio_square-blue',
					increaseArea: '20%' // optional
				});
			});
		</script>
		<script>
			  $('#defaultForm').bootstrapValidator({
//        live: 'disabled',
        message: 'This value is not valid',
        feedbackIcons: {
            valid: 'glyphicon glyphicon-ok',
            invalid: 'glyphicon glyphicon-remove',
            validating: 'glyphicon glyphicon-refresh'
        },
        fields: {
           
            username: {
//              message: 'The username is not valid',
                validators: {
                    notEmpty: {
//                      message: 'The username is required and cannot be empty'
                    },
                   
                }
            },
            password: {
                validators: {
                    notEmpty: {
//                      message: 'The password is required and cannot be empty'
                    },
                   
                }
            }
            
        }
    }) 
    .on('success.form.bv', function(e) {
            // Prevent form submission
            e.preventDefault();
			var name = $(".show_name").val();
				var pas = $(".show_pas").val();
					$.ajax({
						type: "post",
						url: "/login",
						async: true,
						data: {
							//			            id : id,
							username: name,
							password: pas
						},
						success: function(data) {
							console.log(data);
								data = JSON.parse(data);
							if(data.code == 0) {
								location.href = "/user/info";
							} else {
								$(".login-box-msg").html(data.message);
							}

						}
					});
				
				
     });
			
			
			
			
		</script>

	</body>

</html>